﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using BUSINESS_OBJECT;

namespace CRM.admin
{
    public partial class staff : System.Web.UI.Page
    {
        
        
        STAFFI stfcls = new STAFFI();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataTable dt = stfcls.GetRecords(-99, -99, " ", " ", " ", " ", -99, -99, " ", Convert.ToDateTime("1/1/1800"), " ", -99, false, " and ");
                GridView1 .DataSource =dt ;
                GridView1 .DataBind ();
            }
        }

        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if(e.CommandName=="delete")
            {
                DataTable dt=stfcls.GetRecords(Convert.ToInt64(e.CommandArgument.ToString()),-99, " ", " ", " ", " ", -99, -99, " ",Convert.ToDateTime("1/1/1800"), " ", -99, false, " and ");

                stfcls.ID=Convert.ToInt64(dt.Rows[0]["ID"].ToString());
                stfcls.CID = Convert.ToInt64(Session["CID"]);
                stfcls.S_NAME=dt.Rows[0]["S_NAME"].ToString();
                stfcls.S_ADDRESS=dt.Rows[0]["S_ADDRESS"].ToString();
                stfcls.S_CITY=dt.Rows[0]["S_CITY"].ToString();
                stfcls.S_STATE=dt.Rows[0]["S_STATE"].ToString();
                stfcls.S_PHONE_NO=Convert.ToInt64(dt.Rows[0]["S_PHONE_NO"].ToString());
                stfcls.S_EMAIL_ID=dt.Rows[0]["S_EMAIL_ID"].ToString();
                stfcls.S_JOIN_DATE=Convert.ToDateTime(dt.Rows[0]["S_JOIN_DATE"].ToString());
                stfcls.S_DESIGNATION=dt.Rows[0]["S_DESIGNATION"].ToString();
                stfcls.SALARY=Convert.ToInt64(dt.Rows[0]["SALARY"].ToString());
                stfcls.ISDELETED=true;
                stfcls.SaveRecords();
                Response.Redirect("staff.aspx");
            }
        }
    }
}
